$(function(){
    var menuname = $("body").attr("id");
    $("."+menuname).addClass("active");
    $("dt"+"."+menuname).nextUntil("dt").css("display","block");
});
$(function(){
    var w = $(window).width();
    var x = 768;
    if (w >= x) {
      $("dt.drawer-dropdown").on("click", function() {
        if($(this).hasClass("active")){
          $(this).removeClass("active");
          $(this).nextUntil("dt","dd").slideUp();
        }else{
          $("dt.drawer-dropdown").removeClass("active");
          $(this).addClass("active");
          $("dd.drawer-dropdown-menu").slideUp();
          $(this).nextUntil("dt","dd").slideToggle();
        }
      });
    }
    $(function() {
      var replaceWidth = 1279;
      var windowWidth = parseInt($(window).width());
        if(windowWidth >= replaceWidth) {
          $('nav').removeClass("drawer-nav");
        } else {
          $('nav').addClass("drawer-nav");
        }
    });
});
if(!navigator.userAgent.match(/(iPhone|iPad|iPod|Android)/)){
	$(function(){
		var timer = false;
		$(window).resize(function() {
		if (timer !== false) {
			clearTimeout(timer);
		}
		timer = setTimeout(function() {
		//リロードする
		location.reload();
			}, 100);
		});
	});
}
$(function()  {
    var targetImgs = $('img');
    targetImgs.each(function()
    {
      if(this.src.match('_off'))
      {
          this.rollOverImg = new Image();
          this.rollOverImg.src = this.getAttribute("src").replace("_off", "_on");
          $(this.rollOverImg).css({position: 'absolute', opacity: 0});
          $(this).before(this.rollOverImg);

          $(this.rollOverImg).mousedown(function(){
              $(this).stop().animate({opacity: 0}, {duration: 0, queue: false});
          });
          $(this.rollOverImg).hover(function(){
              $(this).animate({opacity: 1}, {duration: 400, queue: false});
          },
          function(){
              $(this).animate({opacity: 0}, {duration: 400, queue: false});
          });
      }
    });
});